home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
music
/
eked-m1.zoo
/
src
/
glob_ed.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-19
|
5KB
|
209 lines
/*
* EKED-M1 : Editor for Korg M1 synth; glob_ed.c : global editor
* Copyright (C) 1995 Steven M. Eker (Steven.Eker@brunel.ac.uk)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stddef.h>
#include <string.h>
#include <gemfast.h>
#include <aesbind.h>
#include "gm/gem_man.h"
#include "eked-m1.h"
#include "defs.h"
#include "types.h"
#include "externs.h"
typedef struct {
int ob_number;
PARA_TYPE type;
} GPARAMETER;
#define GT_SIZE 19
static GPARAMETER glob_table[] =
{
{G_TUNE, SN50},
{G_TRANSPOSE, SN12},
{G_DAMPER, POL},
{G_PEDAL1, PED},
{G_PEDAL2, PED},
{G_SCALE, SCAL},
{G_PURE, KEY},
{G_USER + 1, SN50},
{G_USER + 2, SN50},
{G_USER + 3, SN50},
{G_USER + 4, SN50},
{G_USER + 5, SN50},
{G_USER + 6, SN50},
{G_USER + 7, SN50},
{G_USER + 8, SN50},
{G_USER + 9, SN50},
{G_USER + 10, SN50},
{G_USER + 11, SN50},
{G_USER + 12, SN50}
};
static int in_use;
static OBJECT *global;
static BANK *edit_bank;
static BYTE data[GLOBAL_SIZE];
static int drum_handle[4];
static char *drum_title[] = {
"Drum Kit 1", "Drum Kit 2", "Drum Kit 3", "Drum Kit 4"
};
static void glob_setup();
static void display(int x_pos, int y_pos, GRECT *clip, long usr_val);
static int action(int handle, E_TYPE type, void *event,
int x_pos, int y_pos, long usr_val);
void ge_window(BANK *bank)
{
static char title[] = "Edit Bank 0 Global";
int t;
if(in_use){
fm_alert(1, GLOB_ED_ALERT);
return;
}
rm_gaddr(R_TREE, GLOBAL, &global);
edit_bank = bank;
memcpy(data, bank->data, (size_t) GLOBAL_SIZE);
glob_setup();
title[10] = '0' + bank->bank_nr;
t = wm_open(NAME | CLOSER | FULLER | MOVER | SIZER |
UPARROW | DNARROW | VSLIDE |
LFARROW | RTARROW | HSLIDE,
(GRECT *) 0, title,
global[0].ob_width, global[0].ob_height,
char_w, char_h, &display, &action, 0L);
if(t < 0){
fm_alert(1, WINDOW_ALERT);
return;
}
in_use = TRUE;
bank->glob_win = t;
}
static void glob_setup()
{
int i;
for(i = 0; i < GT_SIZE; i++)
para_fill(global + glob_table[i].ob_number, glob_table[i].type, data + i);
}
static void display(int x_pos, int y_pos, GRECT *clip, long usr_val)
{
global[0].ob_x = x_pos;
global[0].ob_y = y_pos;
objc_draw(global, 0, MAX_DEPTH, clip->g_x, clip->g_y, clip->g_w, clip->g_h);
}
static int action(int handle, E_TYPE type, void *event,
int x_pos, int y_pos, long usr_val)
{
CLICK *c;
int i, ob;
switch(type){
case E_CLEANUP:
for(i = 0; i < 4; i++){
if(drum_handle[i] != 0){
wm_closed(drum_handle[i]);
/*
* We must flush redraws generated by closing a drum window before
* anything else gets closed otherwise they will become stale
* and crash AES.
*/
/* wm_flush(); */
}
}
edit_bank->glob_win = 0;
in_use = FALSE;
break;
case E_MESSAGE:
if(((int *) event)[0] == WM_CLOSED
&& memcmp(data, edit_bank->data, (size_t) GLOBAL_SIZE) != 0){
switch(fm_alert(1, GLOB_QUIT_ALERT)){
case 1: /* save */
memcpy(edit_bank->data, data, (size_t) GLOBAL_SIZE);
break;
case 3: /* cancel */
return R_NOACT;
}
}
break;
case E_CLICK:
c = (CLICK *) event;
global[0].ob_x = x_pos;
global[0].ob_y = y_pos;
ob = objc_find(global, 0, MAX_DEPTH, c->m_x, c->m_y);
switch(ob){
case G_RESET:
if(wm_do_button(handle, global, ob, FALSE)){
memcpy(data, edit_bank->data, (size_t) GLOBAL_SIZE);
glob_setup();
wm_update(handle);
for(i = 0; i < 4; i++){
if(drum_handle[i] != 0)
wm_update(drum_handle[i]);
}
}
break;
case G_SAVE:
if(wm_do_button(handle, global, ob, FALSE))
memcpy(edit_bank->data, data, (size_t) GLOBAL_SIZE);
break;
case G_KIT1:
case G_KIT1 + 1:
case G_KIT1 + 2:
case G_KIT1 + 3:
if(wm_do_button(handle, global, ob, FALSE)){
i = ob - G_KIT1;
if(drum_handle[i] != 0)
wm_topped(drum_handle[i]);
else
drum_handle[i] = de_window(drum_title[i], data + 21 + 210 * i);
}
break;
default:
for(i = 0; i < GT_SIZE; i++){
if(glob_table[i].ob_number == ob){
para_edit(handle, global, ob, glob_table[i].type, -1, -1, data + i);
break;
}
}
}
break;
}
return R_NORMAL;
}
void ge_drumexit(int handle)
{
int i;
for(i = 0; i < 4; i++){
if(drum_handle[i] == handle){
drum_handle[i] = 0;
break;
}
}
}